package com.yj.jason.jsondemo;

import android.content.Context;
import android.graphics.Canvas;
import android.graphics.Color;
import android.graphics.Paint;
import android.graphics.Rect;
import android.graphics.drawable.Drawable;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v4.content.ContextCompat;
import android.support.v7.app.AppCompatActivity;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.TextView;
import android.widget.Toast;

import com.yj.jason.baselibrary.view.RecyclerView.CommonAdapter.CommonRecyclerAdapter;
import com.yj.jason.baselibrary.view.RecyclerView.CommonAdapter.ViewHolder;
import com.yj.jason.moudlelibrary.view.TimelineLayout;

import java.util.ArrayList;
import java.util.List;

public class TimeLineActivity extends AppCompatActivity{
    private TimelineLayout time_line_layout;
    private List<String> mBeans=new ArrayList<>();


    @Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_time_line);
        time_line_layout=(TimelineLayout)findViewById(R.id.time_line_layout);


        for(int i=0;i<20;i++){
            if(i==5){
                addItem2();
            }else {
                addItem();
            }
        }


       time_line_layout.setOnItemClickListener(new TimelineLayout.OnItemClickListener() {
           @Override
           public void onClick(int pos) {
               Toast.makeText(TimeLineActivity.this,"点击了=="+pos,Toast.LENGTH_SHORT).show();
           }
       });


    }

    private int index=0;
    private void addItem() {
        View view = LayoutInflater.from(this).inflate(R.layout.item_time_line, time_line_layout, false);
        ((TextView) view.findViewById(R.id.tv_action)).setText("步骤" + index);
        ((TextView) view.findViewById(R.id.tv_action_time)).setText("2017年3月8日16:55:04");
        ((TextView) view.findViewById(R.id.tv_action_status)).setText("完成");
        time_line_layout.addItemView(view,index);
        index++;


    }


    private void addItem2() {
        View view = LayoutInflater.from(this).inflate(R.layout.item_time_line, time_line_layout, false);
        ((TextView) view.findViewById(R.id.tv_action)).setText("就是地方势力扩大飞机是否士大夫艰苦撒旦解放上的JFK圣诞节分厘卡圣诞节发可是老大JFK圣诞节福克斯的疯狂路上的风景撒开绿灯解放昆仑山大幅加快速度见风使舵快来解放圣诞快乐尖峰时刻的" + index);
        ((TextView) view.findViewById(R.id.tv_action_time)).setText("2017年3月8日16:55:04发射点发射点发生觉得开发商的封建时代反倒是克里夫就是看到了JFK是大幅加快速度封建时代福克斯独立解放昆仑山搭街坊是大家看法圣诞快乐房价舍得离开房间上帝就发sd");
        ((TextView) view.findViewById(R.id.tv_action_status)).setText("完成");
        time_line_layout.addView(view);
        index++;
    }

    private void subItem() {
        if (time_line_layout.getChildCount() > 0) {
            time_line_layout.removeViews(time_line_layout.getChildCount() - 1, 1);
            index--;
        }
    }

}
